import ApiBase from './ApiBase';
import type { TPromiseApiResult } from '@/types/apis';
import type { ILoginReq, ILoginRes, IGetUserInfoReq, IGetUserInfoRes } from '@/types/apis/user-api';
import { EUserRole } from '@/types/apis/user-api';
import { mockAxiosRes } from '@hdtd/utils';

export default class UserApi extends ApiBase {
  /**
   * 登录接口
   * @param data
   * @returns
   */
  login(data: ILoginReq): TPromiseApiResult<ILoginRes> {
    return mockAxiosRes({
      code: 200,
      data: {
        token: '123'
      },
      msg: ''
    });
    return this.httpClient.get('/login', {
      ...this.config,
      params: data
    });
  }

  getUserInfo(data: IGetUserInfoReq): TPromiseApiResult<IGetUserInfoRes> {
    return mockAxiosRes({
      code: 200,
      data: {
        id: 1,
        roles: [EUserRole.Admin],
        userNme: '张三'
      },
      msg: '请求成功'
    });
    return this.httpClient.get('/user-info', {
      ...this.config,
      params: data
    });
  }
}
